﻿using System.Text;

namespace flygame2
{
    /// <summary>
    /// 用来表示二维向量的结构体
    /// </summary>
    struct Vector2
    {
        public int posX;
        public int posY;

        public Vector2(int x, int y)
        {
            posX = x;
            posY = y;
        }

        public override string ToString()
        {
            return $"({posX}, {posY})";
        }

        public static Vector2 operator +(Vector2 a, Vector2 b)
        {
            return new Vector2(a.posX + b.posX, a.posY + b.posY);
        }

        public static Vector2 operator -(Vector2 a, Vector2 b)
        {
            return new Vector2(a.posX - b.posX, a.posY - b.posY);
        }
    }

    /// <summary>
    /// 游戏对象类型枚举
    /// </summary>
    enum GameObjectType
    {
        Normal = 0,// 普通物体
        Pause = 1, // 暂停
        Rulette = 2, // 转盘
        Tube = 3, // 管道
        Mine = 4, // 地雷
        Player1 = 5, // 玩家
        Player2 = 6, // 玩家2
    }


    /// <summary>
    /// 游戏对象结构体
    /// </summary>
    struct GameObject
    {
        public Vector2 pos;
        public string name;
        public string icon;

        public GameObjectType type;
        public GameObject(Vector2 position, string objectName,GameObjectType objectType)
        {
            pos = position;
            name = objectName;
            type = objectType;
        }

        public void Draw()
        {
            Console.SetCursorPosition(pos.posX, pos.posY);
            switch(type)
            {
                case GameObjectType.Normal:
                    Console.ForegroundColor = ConsoleColor.White; // 普通物体为白色
                    icon = "□"; // 假设普通物体的图标是"O"
                    break;
                case GameObjectType.Pause:
                    Console.ForegroundColor = ConsoleColor.Yellow; // 暂停为黄色
                    icon = "||"; // 假设暂停的图标是"||"
                    break;
                case GameObjectType.Rulette:
                    Console.ForegroundColor = ConsoleColor.Cyan; // 转盘为青色
                    icon = "⏳"; // 假设转盘的图标是"⏳"
                    break;
                case GameObjectType.Tube:
                    Console.ForegroundColor = ConsoleColor.Green; // 管道为绿色
                    icon = "⏹"; // 假设管道的图标是"⏹"
                    break;
                case GameObjectType.Mine:
                    Console.ForegroundColor = ConsoleColor.Red; // 地雷为红色
                    icon = "💣"; // 假设地雷的图标是"💣"
                    break;
                case GameObjectType.Player1:
                    Console.ForegroundColor = ConsoleColor.Blue; // 玩家1为蓝色
                    icon = "👤"; // 假设玩家1的图标是"👤"
                    break;
                case GameObjectType.Player2:
                    Console.ForegroundColor = ConsoleColor.Magenta; // 玩家2为品红色
                    icon = "👥"; // 假设玩家2的图标是"👥"
                    break;
                default:
                    Console.ForegroundColor = ConsoleColor.Gray; // 默认灰色
                    icon = "□"; // 未知类型的图标是"?"
                    break;
            }
            // 这里可以添加绘制逻辑
            Console.Write(icon);
            Console.ResetColor(); // 重置颜色
        }

    }

    struct Map
    {
        private GameObject[] gameObjects; // 存储游戏对象的数组
        private int length; 

    }



    internal class Program
    {
        static void Main(string[] args)
        {
            // 设置控制台输出编码为 UTF-8
            Console.OutputEncoding = Encoding.UTF8;

            GameObject gameObject = new GameObject(new Vector2(10, 5), "Player1", GameObjectType.Player1);
            gameObject.Draw(); // 绘制游戏对象

            GameObject gameObject1 = new GameObject(new Vector2(15, 5), "Tube", GameObjectType.Tube);
            gameObject1.Draw(); // 绘制游戏对象
        }
    }
}
